<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <!--    <script src="/static/js/framework-ui.js"></script>-->
    <!--    <script src="/static/js/framework-clientdata.js"></script>-->

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--    配置select多选相关-->
    <!--    <script src="/static/layui/dist/xm-select.js"></script>-->


        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}

    <script src="/static/build/tracking-min.js"></script>
    <script src="/static/build/data/face-min.js"></script>
    <script src="/static/build/data/eye-min.js"></script>
    <script src="/static/build/data/mouth-min.js"></script>
</head>
<body>
<style>
    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }

    .new-content {
        padding: 15px 0px
    }

    .config_img {
        max-width: 150px;
        max-height: 150px;
        margin-top: 15px;
    }
</style>

<div class="modal-body">


    <div class="modal-header">

        <div class="assistant_header">
            <button type="button" class="close" data-dismiss="modal" close="true">
                <span aria-hidden="true">×</span>
            </button>
            <h4 class="modal-title">
                <span class="fa fa-legal"></span>添加内容
            </h4>
        </div>
    </div>

    <div class="new-content">
        <form class="form-horizontal layui-form">


            <div class="form-group">

                <label class="col-sm-1 control-label">*所属分类:</label>
                <div class="col-sm-3">
                    <select name="ptt_id" lay-verify="classify_id" lay-filter="classify_id" class="select"  lay-search="">
                        {volist name="classify" id="vo"}
                        <option value="{$vo.id}" {if condition="$detail['ptt_id'] eq $vo['id']"} selected {/if} >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-1 control-label newtitle">标题:</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" name="title" value="{$detail.title}" placeholder="标题">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-1 control-label">缩略图:</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="text" id="thumb" name="thumb" value="{$detail.thumb}" class="form-control" autocomplete="off">
                        <span class="input-group-btn">
                        <button class="btn btn-default" id="upload" type="button" data-original-title="" title="">选择图片</button>
                    </span>
                    </div>

                    {if condition="$detail['thumb'] eq ''"}
                    <img class="config_img thumb" src="/static/images/nopic-107.png" >
                    {else/}
                    <img class="config_img thumb" src="{$detail.thumb}" >
                    {/if}


                </div>
            </div>

            <div  class="form-group" >
                <label class="col-sm-1 control-label">简介:</label>
                <div class="col-sm-8">
                    <textarea name="desc" class="layui-textarea">{$detail.desc}</textarea>
                </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-1 control-label">APPID:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="appid" placeholder="APPID"  value="{$detail.appid}">
                </div>
            </div>
            <div class="form-group" >
                <label class="col-sm-1 control-label">小程序路径:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="applink" placeholder="小程序路径" value="{$detail.applink}">
                </div>
            </div>

            <!--外部链接-->
            <div class="form-group" >
                <label class="col-sm-1 control-label">链接地址:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="link" value="{$detail.link}" placeholder="链接地址">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-1 control-label">排序:</label>
                <div class="col-sm-2">
                    <input type="text" class="form-control" name="sort" value="{$detail.sort}" placeholder="排序">
                </div>

                <label class="col-sm-1 control-label">状态:</label>
                <div class="col-sm-2">
                    <select name="status">
                        <option value="1" {if condition="$detail['status'] eq 1"} selected {/if}>启用</option>
                        <option value="2" {if condition="$detail['status'] eq 2"} selected {/if}>禁用</option>
                    </select>
                </div>
            </div>

            <input type="hidden" name="id" value="{$detail.id}">
        </form>

    </div>
    <div class="assistant_button">
        <a type="button" class="layui-btn layui-btn-primary js_quit" href="{:URL('admin/ptt/index')}" >取消</a>
        <!--        <button type="button" class="btn btn-primary btn-sm js_add" _event="add" data-id="0" data-name="">保存</button>-->
        <a type="button" class="layui-btn js_add" id="newsave">保存</a>
    </div>

</div>


<script>
    var newModal = new yii.modal();
    //文件页面
    $("#upload").click(function () {
        $(newModal.getid()).show();
        newModal.initialization({
            url: "{:URL('common/upload/index')}",
            type: "post",
            data:{
                type:'detail'
            }
        });
    });

    newModal.on("upload",function(data){
        var images = '';
        $(newModal.getid()).find("#data-area .newimages .active img").each(function () {
            images = $(this).attr('src');
            return false
        })
        $(newModal.getid()).hide();
        //$(".modal-backdrop").remove();
        //$('#nowMainProjectDataForm').modal('hide');
        $(newModal.getid()).find(".modal").hide();
        $("#thumb").val(images);
        $(".config_img").attr("src",images)
    });



    layui.use(['form', 'jquery', 'layer', 'laydate','layedit'], function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: "{:URL('/common/upload/textUpload')}" //接口url
                ,type: '' //默认post
            }
        });

        var editIndex = layedit.build('content');

        var content = layedit.getContent(editIndex);


        $("#newsave").click(function () {
            // var content = layedit.getContent(editIndex);
            var data = $("form").serializeArray();
            // data.push({name: "desc", value: content});
            $.ajax({
                type: 'post',
                url: "{:URL('admin/ptt/doLists')}",
                data: data,
                dataType: 'JSON',
                success: function (res) {
                    if (res.code != 0) {
                        layer.alert(res.msg);
                    } else {
                        window.location.href = "{:URL('admin/ptt/index')}";
                    }
                },
                error: function (res) {

                }
            });
        })


        form.render('select');

    });

</script>

</body>
</html>